package com.software.frontend.firstPage;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

import com.software.frontend.R;
import com.software.frontend.firstPage.entity.Post;
import com.software.frontend.firstPage.simple.DefaultUseInLocalActivity;

import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard;

public class YouYouJIanDetailsPageActivity extends AppCompatActivity {

    private Post post;
    private JCVideoPlayerStandard jcVideoPlayerStandard;
    private ImageButton likeBtn,commentsBtn;
    private TextView likeCount, userName, videoTitle;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_you_you_jian_details_page);
        //获取intent和携带的数据
        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();
        post = (Post) bundle.getSerializable("post");

        //getSupportActionBar().setTitle("jiecaovideoplayer的使用");
        likeBtn = findViewById(R.id.youYouJIan_likePic);
        likeCount = findViewById(R.id.youYouJIan_likeCount);
        commentsBtn = findViewById(R.id.youYouJIan_commentsPic);
        userName = findViewById(R.id.youYouJIan_userName);
        videoTitle = findViewById(R.id.youYouJIan_videoTitle);
        jcVideoPlayerStandard = findViewById(R.id.youYouJIan_jieCao_Player);
        jcVideoPlayerStandard.setUp(post.getMediaContentPath(),jcVideoPlayerStandard.SCREEN_WINDOW_FULLSCREEN,"视频标题");

        likeBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                likeBtn.setImageResource(R.mipmap.you_you_j_ian_heart_like);
            }
        });
        commentsBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intentTo;
                intentTo = new Intent(YouYouJIanDetailsPageActivity.this, DefaultUseInLocalActivity.class);
                startActivity(intentTo);
            }
        });
        likeCount.setText(post.getLikeCount() + "万");
        userName.setText("@" + post.getUserId());
        videoTitle.setText(post.getWordContent());
    }

    @Override
    public void onBackPressed() {
        if (JCVideoPlayer.backPress()){
            return;
        }
        super.onBackPressed();
    }

    @Override
    protected void onPause() {
        super.onPause();
        JCVideoPlayer.releaseAllVideos();
    }
}